using System.ComponentModel.DataAnnotations.Schema;
using System.Data.Entity.ModelConfiguration;

namespace QuanLyNganHangDe.DAL.Models.Mapping
{
    public class KhoiMap : EntityTypeConfiguration<Khoi>
    {
        public KhoiMap()
        {
            // Primary Key
            this.HasKey(t => t.MaKhoi);

            // Properties
            this.Property(t => t.MaKhoi)
                .IsRequired()
                .HasMaxLength(50);

            this.Property(t => t.TenKhoi)
                .HasMaxLength(50);

            this.Property(t => t.MaHocPhan)
                .IsRequired()
                .HasMaxLength(50);

            // Table & Column Mappings
            this.ToTable("Khoi");
            this.Property(t => t.MaKhoi).HasColumnName("MaKhoi");
            this.Property(t => t.TenKhoi).HasColumnName("TenKhoi");
            this.Property(t => t.MaHocPhan).HasColumnName("MaHocPhan");
            this.Property(t => t.SoDiem).HasColumnName("SoDiem");
            this.Property(t => t.Stt).HasColumnName("Stt");

            // Relationships
            this.HasRequired(t => t.HocPhan)
                .WithMany(t => t.KhoiCollection)
                .HasForeignKey(d => d.MaHocPhan);

        }
    }
}
